import React, { Component } from 'react'
import List_header from './header/list_header'
import Nav from "./nav/list_nav"
import Main from "./main/list_main"
import Foot from "../../components/foot_router/foot_router"
import Chouti from './chouti/chouti'
import axios from 'axios'
export default class Center extends Component {
    state = {
        flag: false,
        tflag: true,
        Time:'',
        shoplist:[111.222],
        time:''
    }
    changeCity = (list) => {
        this.state.citylist = list
    }
    changeChouti = () => {
        clearTimeout(this.state.iTime);
        this.state.iTime = setTimeout(() => {
            this.state.flag = !this.state.flag
            this.setState({})
        }, 200);

    }
    changeShopList=(values)=>{
        this.setState({
            shoplist:values,
            time:new Date().getTime()
        })
        console.log(this.state.shoplist)
    }
    componentDidMount(){
        axios.get('/shop/getall').then(res=>{
            this.setState({
                shoplist:res.data.lists,
                time:new Date().getTime()
            })
        })
        console.log(this.header)
    }

    
    render() {
        return (
            <div>
                <div>
                    <List_header changeShopList={this.changeShopList}  key={this.state.flag} changeChouti={this.changeChouti} />
                    <Nav changeShopList={this.changeShopList}/>
                    <Main key={this.state.time} shoplist={this.state.shoplist} />
                    <Foot />
                    <Chouti flag={this.state.flag} changeChouti={this.changeChouti} />
                </div>

            </div>
        )
    }
}
